<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e"
      >
    </ex_super_table_page>
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import emitOnFunction from '@/mixin/emit-on-function';

import page_table_model_manage from '@/mixin/page_table_model_manage';
let emitKey = 'warehouse_appointment>confirm'

export default {
  title: 'title_warehouse_appointment',
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],

  data() {
    return {
      selection: [],

      option: {
        search: {
          model: [
            { label: "label_warehouse_name", key: "warehouseId", type: 'select', option: { label: 'warehouseName', value: 'warehouseId' }, url: '/oms-api/order/OmsInboundScheduleAnalyseRpc/selectWarehouse.json' },
            { label: "label_expected_arrival_date", key: "expectedDate", type: 'date-picker', attrs: { type: 'datetimerange' }, keyExtra: { _emitKey: 'input', 0: 'expectedBeginDate', 1: 'expectedEndDate' } },
          ],
        },
        actionExtra: [
          {
            label: 'label_export', attrs: { type: "primary" },
            auth: 'oms_warehouse_appointment_export',
            click: this.exportExcel
          },
        ],
        table: {
          url: "/oms-api/order/OmsInboundScheduleAnalyseRpc/selectPage.json",
          model: this.option_table_model(),
        },
      },
    };
  },
  methods: {
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true, keyGroup: 'label_table_operate' },
        {
          key: 'expectedDate', label: 'label_date', minWidth: 160, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$dateFormat(v)
        },
        { key: 'warehouseName', label: 'label_inbound_warehouse', minWidth: 100, 'show-overflow-tooltip': true },
        { key: 'scheduleCustomerNum', label: 'label_declare_customer_count', width: 80, 'show-overflow-tooltip': true },
        { key: 'scheduleWeight', label: 'label_declare_goods_sum_weight', width: 80, 'show-overflow-tooltip': true },
        { key: 'scheduleVolumn', label: 'label_declare_goods_sum_volume', width: 80, 'show-overflow-tooltip': true },
        { key: 'schedulePackagingQty', label: 'label_declare_goods_sum_package_count', width: 100, 'show-overflow-tooltip': true },
        { key: 'scheduleBoxQty', label: 'label_declare_goods_sum_box_count', width: 100, 'show-overflow-tooltip': true },
        { key: 'warehouseCapacity', label: 'label_warehouse_capacity', width: 100, 'show-overflow-tooltip': true, },
        { key: 'capacityRate', label: 'label_warehouse_setting_capacity_rate', width: 100, 'show-overflow-tooltip': true, },
        { key: 'configNum', label: 'label_warehouse_setting_operate_amount', width: 80, 'show-overflow-tooltip': true },
        { key: 'practicalCustomerNum', label: 'label_actual_arrival_goods_customer_count', width: 80, 'show-overflow-tooltip': true },
        { key: 'practicalPackagingQty', label: 'label_actual_arrival_goods_sum_package_count', width: 100, 'show-overflow-tooltip': true },
        { key: 'practicalBoxQty', label: 'label_actual_arrival_goods_sum_box_count', width: 100, 'show-overflow-tooltip': true },
        { key: 'practicalWeight', label: 'label_actual_arrival_goods_sum_weight', width: 100, 'show-overflow-tooltip': true },
        { key: 'practicalVolumn', label: 'label_actual_arrival_goods_sum_volume', width: 100, 'show-overflow-tooltip': true },
        {
          type: 'operate',
          width: 160,
          fixed: "right",
          operate: [
            {
              label: "title_appointment_report_list",
              click: (row, i) => {
                this.$router.push({
                  path: './appointment_report_list', query: { warehouseId: row.warehouseId, expectedDate: row.expectedDate }
                })
              }
            },
          ]
        }
      ]
    },
    exportExcel() {
      const params = this.$refs.SuperTablePage.getSearchFormData()


      const scheduleAnalyseIds = []
      this.selection.forEach(item => {
        scheduleAnalyseIds.push(item.id)
      })
      this.$downloadFile({
        url: '/oms-api/order/OmsInboundScheduleAnalyseRpc/exportExcel.json',
        window: true,
        data: {
          ...params,
          scheduleAnalyseIds: scheduleAnalyseIds.toString()
        }
      })
    },

  }
};

</script>
<style></style>
